<template>
    <div class="container">
        <h1>3D 悬停卡片效果</h1>

        <div class="cards-container">
            <div v-for="(card, index) in cards" :key="index" class="card">
                <!-- 反光层 -->
                <div class="card-glare"></div>

                <!-- 图标 -->
                <div class="card-icon">
                    <i :class="card.icon"></i>
                </div>

                <!-- 标题 -->
                <h3 class="card-title">{{ card.title }}</h3>

                <!-- 内容 -->
                <p class="card-content">{{ card.content }}</p>

                <!-- 按钮 -->
                <button class="card-button">探索更多</button>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';

// 定义卡片数据
const cards = ref([
    {
        icon: 'fas fa-rocket',
        title: '创新技术',
        content: '采用前沿技术栈，打造高性能、高可用的现代化应用解决方案。'
    },
    {
        icon: 'fas fa-paint-brush',
        title: '精美设计',
        content: '注重每一个细节，为用户提供直观、愉悦的视觉与交互体验。'
    },
    {
        icon: 'fas fa-code',
        title: '优质代码',
        content: '遵循最佳实践，编写清晰、可维护且经过充分测试的代码。'
    }
]);
</script>

<style scoped>
.container {
    max-width: 100%;
    text-align: center;
    color: white;
    background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
    padding: 20px;
}

h1 {
    font-size: 2.8rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
}

.cards-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    perspective: 1000px;
}

.card {
    width: 300px;
    height: 380px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: all 0.5s;
}

.card:hover {
    transform: translateY(-15px) rotateX(5deg) rotateY(-5deg) scale(1.03);
    box-shadow: 0 20px 30px rgba(0, 0, 0, 0.3);
}

.card:hover::before {
    transform: translateX(100%);
}

.card-icon {
    font-size: 60px;
    margin-bottom: 25px;
    color: #fff;
    transition: all 0.3s ease;
    transform: translateZ(30px);
}

.card:hover .card-icon {
    transform: translateZ(50px) scale(1.2);
    color: #ffdb58;
}

.card-title {
    font-size: 26px;
    font-weight: 700;
    color: white;
    margin-bottom: 15px;
    transition: all 0.3s ease;
    transform: translateZ(20px);
}

.card:hover .card-title {
    transform: translateZ(40px);
    color: #ffdb58;
}

.card-content {
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
    margin-bottom: 25px;
    transform: translateZ(10px);
    transition: all 0.3s ease;
}

.card:hover .card-content {
    transform: translateZ(30px);
}

.card-button {
    padding: 12px 30px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    transform: translateZ(10px);
    margin-top: auto;
}

.card-button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateZ(30px) scale(1.05);
}

.card-glare {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    overflow: hidden;
    pointer-events: none;
}

.card-glare::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: rotate(45deg);
    transition: all 0.5s ease;
    opacity: 0;
}

.card:hover .card-glare::after {
    opacity: 1;
    animation: glare 1.5s ease-in-out;
}

@keyframes glare {
    0% {
        transform: rotate(45deg) translate(-50%, -50%);
    }

    100% {
        transform: rotate(45deg) translate(50%, 50%);
    }
}
</style>